/*
 * ICfg/CfgParams.h
 *
 *  Created on: 10 Mar 2011
 *      Author: Bagrat Aznauryan
 */
#ifndef CFGPARAMS_H_
#define CFGPARAMS_H_

//#pragma pack(1)
#include "lwip/ip_addr.h"
#pragma region Configuration parameters
extern unsigned char CfgFileExist;

struct SG_UnitId
{
	char param_user[16];
	char param_unit[16];
	char param_loc[16];
};
struct SG_Data_IF
{
	unsigned char param_primary_interface_select;
	unsigned char param_interface_timeout;
	unsigned int  param_baud_rate;
	unsigned char param_data_bits;
	unsigned char param_parity;
	unsigned char param_stop_bits;
	unsigned char param_flow_control;
};
struct SG_Sleep
{
	unsigned char param_sleep_reg;			// MODE
	unsigned char param_quit;				//
	unsigned char param_wakeup;				//(Timer)
};

struct G_OPER
{
	struct SG_UnitId SG_DeviceIndividualization;
	struct SG_Data_IF SG_Data_Interface;
	struct SG_Sleep  SG_SleepMode;
};


struct SG_UHF
{
	unsigned char param_channel_num;
	char param_output_pow;
	unsigned char param_modulation;
	unsigned char param_fec;
	unsigned char param_scram;
	unsigned short param_carrier_freq_number;
	unsigned char param_freq_number_symbolrate;
};

struct G_WIRELESS
{
	struct SG_UHF SG_Uhf;
};
////////////////////////////////////////////////////////////////////////////
struct Parameter_bridging
{
	unsigned bridging_protocol : 4;
	unsigned reserved : 3;
	unsigned pmp : 1;
};
struct Parameter_snmp
{
	unsigned snmp_protocol_selector : 4;
	unsigned reserved : 3;
	unsigned trap_timeout_en_dis : 1;
};
struct SG_NetProtSet
{
	struct Parameter_bridging param_bridging_reg;
	struct Parameter_snmp param_snmp_protocol_reg;
	unsigned short param_snmp_traptimeout;
};
struct Parameter_wifi
{
	unsigned reserved : 4;
	unsigned conn_even : 1;
	unsigned conn_preferred : 1;
	unsigned conn_automaticaly : 1;
	unsigned wifi_network_type : 1;
};
struct SG_WiFiSet
{
	struct Parameter_wifi  network_register;
	char access_point_name[32];
	char ssid[32];
};
struct Parameter_tcpip
{
	unsigned reserved : 7;
	unsigned dhcp : 1;
};
struct SG_TCPIPSet
{
	struct Parameter_tcpip param_tcpip_reg;
	struct ip_addr param_ip_address;
	struct ip_addr param_subnet_mask;
	struct ip_addr param_default_gateway;
	struct ip_addr param_dns_server;
};
struct SG_NetSec
{
	unsigned char security_type;
	unsigned char encryption_type;
	char network_security_key[16];
};

struct G_NETWORK
{
	struct SG_NetProtSet SG_NetProtSet;
	struct SG_WiFiSet SG_WiFiSet;
	struct SG_TCPIPSet SG_TCPIPSet;
	struct SG_NetSec  SG_NetSec;
};



struct CfgRoot
{
	struct G_OPER G_Oper;
	struct G_WIRELESS G_Wireless;
	struct G_NETWORK G_Network;
};

struct CfgRoot ConfigRoot;

//////////////////////////////
struct Node_channel
{
	unsigned int freq;
	char pow;
	unsigned char sym_rate;
};

struct Node_channel Current_Channel;
////////////////////////////////

#define CMD_MODE	0
#define DATA_MODE	1
#define NONE_MODE	2

struct OperationMode
{
	unsigned char usb_port_mode;
	unsigned char usart_port_mode;
};

struct OperationMode operation_mode;


void CfgRoot_init(void);
#pragma endregion Configuration parameters

#pragma region Enroll parameters
struct Certification
{
	unsigned short Unit_ID;	
};
struct Certification certefication;
#pragma endregion Enroll parameters
#endif /*CFGPARAMS_H_*/
